<!-- 样品管理 -->
<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="show ? rowObj.T1 : rowObj.F1" :xs="show ? rowObj.T2 : rowObj.F2">
        <workSiteLeft ref="workSiteLeft" :show="show" @showLeft="showLeft" @queryVal="queryVal" />
      </el-col>

      <el-col :span="show ? rowObj.T3 : rowObj.F3" :xs="show ? rowObj.T4 : rowObj.F4">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px" style="display: flex;justify-content: space-between;">
          <div>
            <el-button style="margin: 3px 0 0 0;" size="mini" :icon="show ? 'el-icon-s-fold' : 'el-icon-s-unfold'" circle @click="showLeft(show)"></el-button>
            <el-form-item label="沥青种类" prop="asphaltType">
              <el-select v-model="queryParams.asphaltType" @change="dictSelectChange" placeholder="沥青种类" clearable @keyup.enter.native="handleQuery" style="width: 100%;">  
                <el-option v-for="dict in dict.type.asphalt_variety" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
              </el-select> 
            </el-form-item>

            <el-form-item label="沥青型号" prop="asphaltNo">
              <el-select v-model="queryParams.asphaltNo" placeholder="沥青标号" clearable @keyup.enter.native="handleQuery" style="width: 100%;">  
                <el-option v-for="dict in dictVal" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictLabel"></el-option>
              </el-select>
            </el-form-item>

            <!-- <el-form-item label="试验时间" prop="insertTime">
              <el-date-picker clearable v-model="queryParams.insertTime" type="date" value-format="yyyy-MM-dd" placeholder="试验时间"></el-date-picker>
            </el-form-item> -->

            <el-form-item label="试验时间" prop="id">
              <deatetime ref="deatetime" v-model="queryParams.time"> </deatetime>
            </el-form-item>

            <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['laboratoryManage:sampleManage:query']">搜索</el-button>
            <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> -->
          </el-form-item>
          </div>
        
          <el-form-item>
            <el-button type="success" icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['laboratoryManage:sampleManage:add']">新增</el-button>
            <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> -->
          </el-form-item>
        </el-form>

        <!-- <el-row :gutter="10" class="mb8">
          <el-col :span="1.5"><el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['laboratoryManage:sampleManage:add']">新增</el-button></el-col>
          <el-col :span="1.5"><el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['laboratoryManage:sampleManage:edit']">修改</el-button></el-col>
          <el-col :span="1.5"><el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['laboratoryManage:sampleManage:remove']">删除</el-button></el-col>
          <el-col :span="1.5"><el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['laboratoryManage:sampleManage:export']">导出</el-button></el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row> -->

        <el-table border v-loading="loading" :data="asphaltDataList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="样品编号" align="center" prop="sampleNo" v-if="true" width="" show-overflow-tooltip/>
          <el-table-column label="沥青种类" align="center" prop="asphaltType" width="" show-overflow-tooltip/>
          <el-table-column label="沥青型号" align="center" prop="asphaltNo" width="" show-overflow-tooltip/>
          <el-table-column label="针入度" align="center" prop="" width="" show-overflow-tooltip/>
          <el-table-column label="软化点" align="center" prop="" width="" show-overflow-tooltip/>
          <el-table-column label="延度" align="center" prop="" width="" show-overflow-tooltip/>
          <el-table-column label="判定结果" align="center" prop="" width="" show-overflow-tooltip/>
          <el-table-column label="创建时间" align="center" prop="dischargeTime" width="180">
            <template slot-scope="scope"><span>{{ parseTime(scope.row.dischargeTime, '{y}-{m}-{d}') }}</span></template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['laboratoryManage:sampleManage:edit']">修改</el-button>
              <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['laboratoryManage:sampleManage:remove']">删除</el-button>
              <!-- <el-button size="mini" type="text" icon="el-icon-tickets" @click="handleReportForms(scope.row)" v-hasPermi="['laboratoryManage:sampleManage:preview']">报表预览</el-button> -->
            </template>
          </el-table-column>
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
      </el-col>
    </el-row>

    <!-- 添加或修改沥青拌合站数据对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="70%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="样品编号" prop="sampleNo"><el-input v-model="form.sampleNo" placeholder="样品编号" /></el-form-item>
          </el-col>
          <el-col :span="8">
            <!-- <el-form-item label="沥青种类" prop="asphaltType"><el-input v-model="form.asphaltType" placeholder="沥青种类" /></el-form-item> -->
            <el-form-item label="沥青种类" prop="asphaltType">
              <el-select v-model="form.asphaltType" @change="dictSelectChange" clearable placeholder="沥青种类" style="width: 100%;">
                <el-option v-for="dict in dict.type.asphalt_variety" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
              </el-select>
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <!-- <el-form-item label="沥青标号" prop="asphaltNo"><el-input v-model="form.asphaltNo" placeholder="沥青标号" /></el-form-item> -->
            <el-form-item label="沥青标号" prop="asphaltNo">
              <el-select v-model="form.asphaltNo" placeholder="沥青标号" clearable style="width: 100%;">  
                <el-option v-for="dict in dictVal" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictLabel"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="代表数量" prop="quantity"><el-input v-model="form.quantity" placeholder="代表数量" /></el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出厂批号" prop="lotNo"><el-input v-model="form.lotNo" placeholder="出厂批号" /></el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出厂日期" prop="productionDate">
              <el-date-picker style="width: 100%;" clearable v-model="form.productionDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="出厂日期"></el-date-picker>
              <!-- <el-date-picker style="width: 100%;" clearable v-model="form.productionDate" type="date" value-format="yyyy-MM-dd" placeholder="出厂日期"></el-date-picker> -->
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="样品数量" prop="sampleAmount"><el-input v-model="form.sampleAmount" placeholder="样品数量" /></el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="取样地点" prop="sampleSite"><el-input v-model="form.sampleSite" placeholder="取样地点" /></el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="工程部位" prop="position"><el-input v-model="form.position" placeholder="工程部位" /></el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="主要仪器设备及编号" prop="equipmentNo"><el-input v-model="form.equipmentNo" placeholder="主要仪器设备及编号" /></el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="生产厂家" prop="manufacturer"><el-input v-model="form.manufacturer" placeholder="生产厂家" /></el-form-item>
          </el-col>
        </el-row>
        
        <el-row :gutter="20">
          <div style="width: 100%;display: flex;">
            <div style="width: 90%;">  
              <el-col :span="2">
                <el-form-item label="针入度" prop=""></el-form-item> <!-- 实时位移字段 一次选3条 -->
              </el-col>
              <el-col :span="6">
                <el-form-item label="针入度1" prop="penetrationId1">
                  <el-input style="width: 160px;" v-model="form.penetrationId1" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="针入度2" prop="penetrationId2">
                  <el-input style="width: 160px;" v-model="form.penetrationId2" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="针入度3" prop="penetrationId3">
                  <el-input style="width: 160px;" v-model="form.penetrationId3" placeholder="请输入" />
                </el-form-item>
              </el-col>
            </div>
            <div style="width: 10%;">
              <!-- <div class="ypgl_btn" @click="zrdBtn">选择</div> -->
              <el-button type="primary" size="mini" @click="zrdBtn">选择</el-button>
            </div>
          </div>
        </el-row>
       
        <el-row :gutter="20">
          <div style="width: 100%;display: flex;">
            <div style="width: 90%;">
              <el-col :span="2">
                <el-form-item label="软化点" prop=""></el-form-item> <!-- 温度1  温度2  选一条 -->
              </el-col>
              <el-col :span="6">
                <el-form-item label="测值1" prop="rhd1">
                  <el-input style="width: 160px;" v-model="form.rhd1" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="测值2" prop="rhd2">
                  <el-input style="width: 160px;" v-model="form.rhd2" placeholder="请输入" />
                </el-form-item>
              </el-col>
            </div>
            <div style="width: 10%;">
              <!-- <div class="ypgl_btn" @click="rhdBtn">选择</div> -->
              <el-button type="primary" size="mini" @click="rhdBtn">选择</el-button>
            </div>
          </div>
        </el-row>
       
        <el-row :gutter="20">
          <div style="width: 100%;display: flex;">
            <div style="width: 90%;">
              <el-col :span="2">
                <el-form-item label="延度" prop=""></el-form-item> <!-- 3个位移量  选一条 -->
              </el-col>
              <el-col :span="6">
                <el-form-item label="延度1" prop="yd1">
                  <el-input style="width: 160px;" v-model="form.yd1" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="延度2" prop="yd2">
                  <el-input style="width: 160px;" v-model="form.yd2" placeholder="请输入" />
                </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item label="延度3" prop="yd3">
                  <el-input style="width: 160px;" v-model="form.yd3" placeholder="请输入" />
                </el-form-item>
              </el-col>
            </div>
            <div style="width: 10%;">
              <!-- <div class="ypgl_btn" @click="ydBtn">选择</div> -->
              <el-button type="primary" size="mini" @click="ydBtn">选择</el-button>
            </div>
          </div>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="针入度" :visible.sync="zrdOpen" width="70%" >
      <el-table border v-loading="loading" :data="zrdDataList" size="mini" @selection-change="zrdhandleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" align="center" width="60" type="index"/>
        <el-table-column label="所属试验室" align="center" prop="laboratoryName" width="110" show-overflow-tooltip />
        <el-table-column label="设备名称" align="center" prop="deviceName" width="160" show-overflow-tooltip />
        <el-table-column label="型号/规格" align="center" prop="model" width="110" show-overflow-tooltip />
        <el-table-column label="样品名称" align="center">
          <template slot-scope="scope"><span>{{ scope.row.sampleName || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="技术要求" align="center">
          <template slot-scope="scope"><span>{{ scope.row.jsyq || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="实时位移" align="center">
          <template slot-scope="scope"><span>{{ scope.row.realTimeDisplacement || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="实时温度" align="center">
          <template slot-scope="scope"><span>{{ scope.row.realTimeTemperature || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" width="160">
          <template slot-scope="scope"><span>{{ scope.row.createTime || "-" }}</span></template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="zrdTotal" :page.sync="zrdQueryParams.pageNum" :limit.sync="zrdQueryParams.pageSize" @pagination="zrdBtn" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="multiple" @click="zrdSubmitForm">确 定</el-button>
        <el-button @click="zrdOpen=false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="软化点" :visible.sync="rhdOpen" width="70%">
      <el-table border v-loading="loading" :data="rhdDataList" size="mini" @selection-change="rhdhandleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" align="center" width="60" type="index"/>
        <el-table-column label="所属试验室" align="center" prop="laboratoryName" width="100" show-overflow-tooltip />
        <el-table-column label="设备名称" align="center" prop="deviceName" min-width="130" show-overflow-tooltip />
        <el-table-column label="型号/规格" align="center" prop="model" min-width="100" show-overflow-tooltip />
        <el-table-column label="样品名称" align="center" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.sampleName || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="技术要求" align="center" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.jsyq || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="时间" align="center" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.time || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="试件编号1" align="center" min-width="90" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.num1 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="温度1" align="center" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.temp1 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="试件编号2" align="center" min-width="90" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.num2 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="温度2" align="center" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.temp2 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" width="135">
          <template slot-scope="scope"><span>{{ scope.row.createTime || "-" }}</span></template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="rhdTotal" :page.sync="rhdQueryParams.pageNum" :limit.sync="rhdQueryParams.pageSize" @pagination="rhdBtn" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="single" @click="rhdSubmitForm">确 定</el-button>
        <el-button @click="rhdOpen=false">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="延度" :visible.sync="ydOpen" width="70%">
      <el-table border v-loading="loading" :data="ydDataList" size="mini" @selection-change="ydhandleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" align="center" width="60" type="index"/>
        <el-table-column label="所属试验室" align="center" prop="laboratoryName" show-overflow-tooltip min-width="90" />
        <el-table-column label="设备名称" align="center" prop="deviceName" show-overflow-tooltip min-width="150" />
        <el-table-column label="型号/规格" align="center" prop="model" show-overflow-tooltip min-width="80" />
        <el-table-column label="样品名称" align="center" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.sysl || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="技术要求" align="center" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope"><span>{{ scope.row.sysl || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="位移量(mm)" align="center" min-width="95">
          <template slot-scope="scope"><span>{{ scope.row.length1 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="位移量(mm)" align="center" min-width="95">
          <template slot-scope="scope"><span>{{ scope.row.length2 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="位移量(mm)" align="center" min-width="95">
          <template slot-scope="scope"><span>{{ scope.row.length3 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="延伸速率(mm/min)" align="center" min-width="135">
          <template slot-scope="scope"><span>{{ scope.row.speed1 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="延伸速率(mm/min)" align="center" min-width="135">
          <template slot-scope="scope"><span>{{ scope.row.speed2 || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="当前温度(℃)" align="center" min-width="95">
          <template slot-scope="scope"><span>{{ scope.row.currTemp || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="设定温度值(℃)" align="center" min-width="110">
          <template slot-scope="scope"><span>{{ scope.row.setTemp || "-" }}</span></template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" width="135">
          <template slot-scope="scope"><span>{{ scope.row.createTime || "-" }}</span></template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="ydTotal" :page.sync="ydQueryParams.pageNum" :limit.sync="ydQueryParams.pageSize" @pagination="ydBtn" />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="single" @click="ydSubmitForm">确 定</el-button>
        <el-button @click="ydOpen=false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 报表预览 -->
    <yi-dialog title="报表预览" ref="dialogReportForms" :visible.sync="dialogVisible_report" width="60%" fullscreen isHandle
      :isConfirm="false" top="10vh">
      <ReportRender ref="ReportRender"></ReportRender>
      <div slot="more" class="more">
        <el-button class="print" type="primary" icon="el-icon-printer" size="small" @click="print()" v-hasPermi="['laboratoryManage:sampleManage:export']">打印/导出</el-button>
      </div>
    </yi-dialog>
  </div>
</template>

<script>
import { listAsphaltData, getAsphaltData, delAsphaltData, addAsphaltData, updateAsphaltData } from "@/api/zhgd/asphaltData";
import { penetrationDataList } from "@/api/laboratoryManage/penetrationData";
import { softeningPointDataList } from "@/api/laboratoryManage/softeningPointData";
import { ductilityDataList } from "@/api/laboratoryManage/ductilityData";
import workSiteLeft from "@/views/components/workSiteLeft";
import deatetime from "@/components/Datetime"; // 生产日期

export default {
  name: "sampleManage",
  dicts: ['asphalt_variety', 'asphalt_label', 'emulsified_asphalt', 'liquid_petroleum_asphalt', 'modified_asphalt', 'modified_emulsified_asphalt'],
  data() {
    return {
      dialogVisible_report: false,
      show: true,
      rowObj: {
        T1: 3,
        T2: 24,
        T3: 21,
        T4: 24,
        F1: 0,
        F2: 0,
        F3: 24,
        F4: 24,
      },
      // 字典
      dictVal: [],
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 非三个禁用
      // three: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 沥青拌合站数据表格数据
      asphaltDataList: [],
      // 针入度
      // penetrationId1: '',
      // penetrationId2: '',
      // penetrationId3: '',
      zrdIds: [],
      zrdTotal: 0,
      zrdOpen: false,
      zrdDataList: [],
      zrdQueryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 软化点
      // rhd1: '',
      // rhd2: '',
      rhdIds: [],
      rhdTotal: 0,
      rhdOpen: false,
      rhdDataList: [],
      rhdQueryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 延度
      // yd1: '',
      // yd2: '',
      // yd3: '',
      ydIds: [],
      ydTotal: 0,
      ydOpen: false,
      ydDataList: [],
      ydQueryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        baseCode: undefined,
        deptId: undefined,
        deptPkid: undefined,
        projectId: undefined,
        stationId: undefined,
        matchType: undefined,
        matchName: undefined,
        matchCode: undefined,
        dischargeTime: undefined,
        dischargeTemperature: undefined,
        sluiceTemperature: undefined,
        batchWeight: undefined,
        mixingDuration: undefined,
        asphaltTemperature: undefined,
        asphaltAggregateRatio: undefined,
        insertTime: undefined,
        productionType: undefined,
        projectCode: undefined,
        stationCode: undefined,
        originalId: undefined
      },
      // 表单参数
      form: {
        penetrationId1: '',
        penetrationId2: '',
        penetrationId3: '',
        rhd1: '',
        rhd2: '',
        yd1: '',
        yd2: '',
        yd3: '',
      },
      // 表单校验
      rules: {
        id: [{ required: true, message: "数据主键不能为空", trigger: "blur" }],
        baseCode: [{ required: true, message: "机构code不能为空", trigger: "blur" }],
        projectId: [{ required: true, message: "项目主键不能为空", trigger: "blur" }],
        stationId: [{ required: true, message: "拌合站主键不能为空", trigger: "blur" }],
        matchType: [{ required: true, message: "级配类型不能为空", trigger: "change" }],
        matchName: [{ required: true, message: "配方名称不能为空", trigger: "blur" }],
        matchCode: [{ required: true, message: "配方编号不能为空", trigger: "blur" }],
      }
    };
  },
  components: {
    deatetime,
    workSiteLeft,
  },
  created() {
    this.getList();
    this.getDicts();
    // 字典 
    this.getDicts("asphalt_label").then((response)=>{
      this.dictData1 = response.data  //道路石油沥青
      this.dictVal = response.data
    })
    this.getDicts("emulsified_asphalt").then((response)=>{
      this.dictData2 = response.data  //乳化沥青
    })
    this.getDicts("liquid_petroleum_asphalt").then((response)=>{
      this.dictData3 = response.data  //液体石油沥青
    })
    this.getDicts("modified_asphalt").then((response)=>{
      this.dictData4 = response.data  //改性沥青
    })
    this.getDicts("modified_emulsified_asphalt").then((response)=>{
      this.dictData5 = response.data  //改性乳化沥青
    })
  },
  methods: {
    // 左侧树点击事件
    showLeft(show) {
      this.show = !show;
    },
    queryVal(val) {
      this.queryParams.id = val.id;
      this.handleQuery();
    },
    // 报表预览
    handleReportForms(row) {
      this.dialogVisible_report = true;
    },
    // 获取针入度数据
    zrdBtn() {
      this.zrdOpen = true;
      penetrationDataList(this.queryParams).then((response) => {
        this.zrdDataList = response.data.records;
        this.zrdTotal = response.data.total;
      });
    },
    // 获取软化点数据
    rhdBtn() {
      this.rhdOpen = true;
      softeningPointDataList(this.queryParams).then((response) => {
        this.rhdDataList = response.data.records;
        this.rhdTotal = response.data.total;
      });
    },
    // 获取延度数据
    ydBtn() {
      this.ydOpen = true;
      ductilityDataList(this.queryParams).then((response) => {
        this.ydDataList = response.data.records;
        this.ydTotal = response.data.total;
      });
    },
    // 针入度多选框选中数据
    zrdhandleSelectionChange(selection) {
      this.zrdIds = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      // this.three = selection.length == 3
    },
    // 软化点多选框选中数据
    rhdhandleSelectionChange(selection) {
      this.rhdIds = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    // 延度多选框选中数据
    ydhandleSelectionChange(selection) {
      this.ydIds = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    // 针入度点击确定按钮
    zrdSubmitForm() {
      this.zrdDataList.forEach((item,index) => {
        if(item.id == this.zrdIds[0]){
          this.form.penetrationId1 = item.realTimeDisplacement 
        }
        if(item.id == this.zrdIds[1]){
          this.form.penetrationId2 = item.realTimeDisplacement
        }
        if(item.id == this.zrdIds[2]){
          this.form.penetrationId3 = item.realTimeDisplacement
        }
        // 测试用
        // if(item.id == this.zrdIds[0]){
        //   this.form.penetrationId1 = item.laboratoryName 
        //   this.form.penetrationId2 = item.deviceName
        //   this.form.penetrationId3 = item.model
        // }
      });
      this.zrdOpen = false;
    },
    // 软化点点击确定按钮
    rhdSubmitForm() {
      this.rhdDataList.forEach((item,index) => {
        if(item.id == this.rhdIds[0]){
          this.form.rhd1 = item.temp1 
          this.form.rhd2 = item.temp2
        }
      });
      this.rhdOpen = false;
    },
    // 延度点击确定按钮
    ydSubmitForm() {
      this.ydDataList.forEach((item,index) => {
        if(item.id == this.ydIds[0]){
          this.form.yd1 = item.length1 
          this.form.yd2 = item.length2
          this.form.yd3 = item.length3
        }
      });
      this.ydOpen = false;
    },
    dictSelectChange(val) {
      if(val == "道路石油沥青"){
        this.dictVal = this.dictData1
      }else if(val == "乳化沥青"){
        this.dictVal = this.dictData2
      }else if(val == "液体石油沥青"){
        this.dictVal = this.dictData3
      }else if(val == "改性沥青"){
        this.dictVal = this.dictData4
      }else if(val == "改性乳化沥青"){
        this.dictVal = this.dictData5
      }else if(val == "煤沥青"){
        this.dictVal = []
      }
    },
    /** 查询沥青拌合站数据列表 */
    getList() {
      this.loading = true;
      listAsphaltData(this.queryParams).then(response => {
        this.asphaltDataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        baseCode: undefined,
        deptId: undefined,
        deptPkid: undefined,
        projectId: undefined,
        stationId: undefined,
        matchType: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.$refs.deatetime.startTime = null;
      this.$refs.deatetime.endTime = null;
      this.queryParams.time = [];
      this.queryParams.startTime = "";
      this.queryParams.endTime = "";  
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加沥青拌合站数据";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids
      getAsphaltData(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改沥青拌合站数据";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateAsphaltData(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            addAsphaltData(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除沥青拌合站数据编号为"' + ids + '"的数据项？').then(() => {
        this.loading = true;
        return delAsphaltData(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('zhgd/asphaltData/export', {
        ...this.queryParams
      }, `asphaltData_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>


<style scoped lang="scss">
.ypgl_btn {
  width: 80px;
  text-align: center;
  margin-top: 5px;
  padding: 3px 0; 
  border: 1px solid #555555;
  border-radius: 3px;
  cursor: pointer;
}

::v-deep .el-dialog {
  height: 80vh;
  overflow: auto;
}
</style>